package com.yanqu.road.server.manger.activity.guagifts.service;

import com.google.protobuf.InvalidProtocolBufferException;
import com.yanqu.road.pb.activity.GuaGiftsProto;
import com.yanqu.road.pb.activity.QixiProto;
import com.yanqu.road.pb.syncMessage.SyncMessage;
import com.yanqu.road.server.game.service.IGameServiceCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.guagifts.GuaGiftsModule;
import com.yanqu.road.server.gameplayer.module.activity.qixi.QixiModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.sync.message.SyncResponse;

public class GuaSendGiftAsyncBackServiceCmd implements IGameServiceCommand {
    @Override
    public SyncResponse execute(SyncMessage.Request request) throws InvalidProtocolBufferException {
        SyncResponse syncResponse = new SyncResponse();
        GuaGiftsProto.CrossGuaGiftsSendGiftRespMsg backMsg = GuaGiftsProto.CrossGuaGiftsSendGiftRespMsg.parseFrom(request.getDataBytes());

        long sendUserId = backMsg.getSendUserId();
        GamePlayer player = GamePlayerMgr.getPlayer(sendUserId);
        if (player != null) {
            player.getModule(GuaGiftsModule.class).sendGiftSuccessBack(backMsg);
        }

        return syncResponse;
    }
}
